package com.ruoyi.household.alarm;

import com.ruoyi.common.domain.HouseholdAnd;
import com.ruoyi.household.domain.SysHousehold;
import com.ruoyi.household.service.ISysHouseholdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Component
public class TestService2  {
    @Autowired
    private ISysHouseholdService sysHouseholdService;
    private static final SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
    //每隔一分钟执行一次
    @Scheduled(cron="0 */10 * * * ?")
    public void testCron(){
        System.out.println("定时任务被调用了");
        System.out.println("cron,当前时间：" +format.format(new Date()));

        SysHousehold sysHousehold1 = new SysHousehold();
        List<SysHousehold> sysHouseholds = sysHouseholdService.selectSysHouseholdList(sysHousehold1);
        for (SysHousehold sysHousehold : sysHouseholds) {
            String name = sysHousehold.getName();
            Long status = sysHousehold.getStatus();

            if (status==0){
                System.out.println(name+"干嘛呢，做核酸了");
            }
        }

    }
}

